#include <stdio.h>

#include "nuclei_sdk_hal.h"
#include "nuclei_libopt.h"

#define ARR_SIZE 10

uint8_t uart0_send_buffer[ARR_SIZE]={ 0x11 ,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a};
uint8_t err_count=0;
uint8_t state=0;

void uart0_handler(void)
{
    if(uart_get_error_parity(UART0)!=0)
    {
      err_count++;
    #ifdef CFG_SIMULATION
        pass_fail_simulation(1);
    #endif 
        printf("uart_receiver_parity_int2_3 pass\r\n");
    }
}


void main(void )
{
    __enable_irq();
	ECLIC_Register_IRQ(UART0_IRQn, ECLIC_NON_VECTOR_INTERRUPT,
                                    ECLIC_LEVEL_TRIGGER, 1, 1,
                                    uart0_handler);	

    uart_parity_en(UART0);
    uart_parity_sel(UART0,UART_EVEN_BIT);

    
    uart_init(UART0, 115200,UART_BIT_LENGTH_8);
    uart_enable_err_irq(UART0);


    while(err_count<ARR_SIZE);
    
    while(1);
    
    return;
}
